<!-- 网页使用的语言 -->
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html lang="zh-CN">
    <head>
    <%--	<base href="<%= basePath %>"/>--%>
        <!-- 指定字符集 -->
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <title>修改用户个人信息</title>

        <link href="${pageContext.request.contextPath}/static/css/bootstrap.min.css" rel="stylesheet">
        <script src="${pageContext.request.contextPath}/static/js/jquery-2.1.0.min.js"></script>
        <script src="${pageContext.request.contextPath}/static/js/bootstrap.min.js"></script>

        <script>
            //页面加载函数
            $(function () {
                //返回
                $("#back").click(function () {
                    location.href="${pageContext.request.contextPath}/myself/toMySelf";
                })

                $("#tosubmit").click(function () {

                    $.ajax({url:"${pageContext.request.contextPath}/myself/update",
                        type :"post",
                        data:$("#updateForm").serialize(),
                        dataType:"json",
                        success:function (data) {
                            if (data.flag){
                                location.href="${pageContext.request.contextPath}/myself/commentsList";
                            }else{
                                //alert("111")
                                $("#updatemsg").html(data.errorMsg)
                            }

                        },
                        error:function (data) {
                            //alert(3);

                        },
                    });
                    return false;
                })
            })
        </script>
        
    </head>
    <body>
    <c:import url="component/header.jsp"></c:import>
        <div class="container" style="width: 400px;">
        <h3 style="text-align: center;">修改个人信息</h3>
        <form action="" id="updateForm" method="post">
          <div class="form-group">
            <label for="name">姓名：</label>
            <input type="text" class="form-control" id="name" name="name"   placeholder="请输入姓名" value="${sessionScope.user.name}"/>
          </div>
            <div class="form-group">
                <label for="username">用户名：</label>
                <input type="text" class="form-control" id="username" name="username" readonly="readonly" placeholder="请输入用户名" value="${sessionScope.user.username}">
            </div>
            <div class="form-group">
                <label for="password">密码：</label>
                <input type="text" class="form-control" id="password" name="password" placeholder="请输入密码" value="">
            </div>


          <div class="form-group">
            <label for="email">Email：</label>
            <input type="text" class="form-control" id="email" name="email" placeholder="请输入邮箱地址" value="${sessionScope.user.email}"/>
          </div>

             <div class="form-group" style="text-align: center">
                <input class="btn btn-primary" id="tosubmit" type="submit" value="提交"  />
                <input class="btn btn-default" type="reset" value="重置" />
                <input class="btn btn-default" type="button" id="back" value="返回"/>
             </div>
            <span id="updatemsg" style="color: red;"></span>
        </form>
        </div>
    </body>
</html>